#include "actionmanager.h"
#include <algorithm>

namespace xl {

ActionManager::ActionManager(QObject* parent) : QObject(parent) { }

ActionManager::~ActionManager() { }

QAction* ActionManager::action(const QString& name) const
{
    auto it = std::find_if(actions_.constBegin(), actions_.constBegin(),
                           [name](const QAction* a) { return a->objectName() == name; });
    return (it != actions_.constEnd() ? *it : nullptr);
}

void ActionManager::addAction(QAction* action)
{
    Q_ASSERT(action);
    actions_.push_back(action);
}

} // namespace xl
